package com.ATM;

import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.ImageIO;

public class IndexPanel extends JPanel {

	private BufferedImage image;

	public IndexPanel() {
		setLayout(null);

		try {
			// 加载图片
			image = ImageIO.read(new File("index.jpg"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		if (image != null) {
			// 获取面板大小
			int panelWidth = getWidth();
			int panelHeight = getHeight();

			// 绘制缩放后的图片
			g.drawImage(image, 0, 0, panelWidth, panelHeight, this);
		}
	}
}
